import React from 'react'
import { download } from '@js/downloadRename'
import style from './Index.module.less'

function Main ({ value, empty }) {
  if (typeof empty === 'function' && (!(value instanceof Array) || value.length === 0)) {
    return <span>{empty()}</span>
  }
  if (!(value instanceof Array)) {
    return <span />
  }
  return (
    <span className={style.links}>
      {
        value.map((li, i) => {
          return (
            <span key={i} className={style.link}>
              <span>{i + 1}、</span>
              <a onClick={() => download(li.path, li.original_filename)}>{li.original_filename}</a>
              <span>；</span>
            </span>
          )
        })
      }
    </span>
  )
}

export default Main
